Provide a reason for not acceptable server request rejections - #2607
Provide a reason for not acceptable server request rejections#2607david-perez wants to merge 1 commit into
Conversation
This commit makes it so that when an incoming request's `Accept` header value set cannot be satisfied by the server, the unsatisfiable value set is stored in the `RequestRejection`. The rejection reason will thus be `DEBUG`-logged.
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
| } | ||
| // Must be of the form: type/subtype | ||
| // Must be of the form: `type/subtype`. | ||
| let content_type = content_type |
There was a problem hiding this comment.
Side note: I feel like this conversion can be done in a static once_cell::Lazy outside of this function, then we pass the &Mime into this function instead. That way we're not doing it over and over.
There was a problem hiding this comment.
I looked at Mime::parse and it appears to be a non-negligible process, so putting Mime behind a OnceCell and incurring an atomic read should indeed speed things up.
I also learnt that mime is not actively maintained, and stumbled upon mediatype, which is const-constructible, so for our static mime type coming from the sSDK I think it would make more sense to switch to that. It's also zero-copy, so parsing the request's Accept and Content-Type headers' mime types and performing the type + subtype equality check should be faster.
| // This is used across different protocol-specific `rejection` modules. | ||
| #[derive(Debug, Error)] | ||
| pub enum NotAcceptableReason { | ||
| #[error("cannot satisfy any of `Accept` header values: {0:?}")] |
## Description Do not parse and initialize the mime, known at compile time, on every request. See #2607 (comment) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
## Description Do not parse and initialize the mime, known at compile time, on every request. See #2607 (comment) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
## Description Do not parse and initialize the mime, known at compile time, on every request. See #2607 (comment) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
## Description Do not parse and initialize the mime, known at compile time, on every request. See #2607 (comment) ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
This commit makes it so that when an incoming request's
Acceptheadervalue set cannot be satisfied by the server, the unsatisfiable value set
is stored in the
RequestRejection. The rejection reason will thus beDEBUG-logged.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.